| string (1) | basic_string& append (const basic_string& str); |
|---|---|
| substring (2) | basic_string& append (const basic_string& str, size_type subpos, size_type sublen); |
| c-string (3) | basic_string& append (const charT* s); |
| buffer (4) | basic_string& append (const charT* s, size_type n); |
| fill (5) | basic_string& append (size_type n, charT c); |
| range (6) | template <class InputIterator> basic_string& append (InputIterator first, InputIterator last); |
| string (1) | basic_string& append (const basic_string& str); |
|---|---|
| substring (2) | basic_string& append (const basic_string& str, size_type subpos, size_type sublen); |
| c-string (3) | basic_string& append (const charT* s); |
| buffer (4) | basic_string& append (const charT* s, size_type n); |
| fill (5) | basic_string& append (size_type n, charT c); |
| range (6) | template <class InputIterator> basic_string& append (InputIterator first, InputIterator last); |
| initializer list(7) | basic_string& append (initializer_list<charT> il); |
| string (1) | basic_string& append (const basic_string& str); |
|---|---|
| substring (2) | basic_string& append (const basic_string& str, size_type subpos, size_type sublen = npos); |
| c-string (3) | basic_string& append (const charT* s); |
| buffer (4) | basic_string& append (const charT* s, size_type n); |
| fill (5) | basic_string& append (size_type n, charT c); |
| range (6) | template <class InputIterator> basic_string& append (InputIterator first, InputIterator last); |
| initializer list(7) | basic_string& append (initializer_list<charT> il); |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// appending to string
#include <iostream>
#include <string>
int main ()
{
std::string str;
std::string str2="Writing ";
std::string str3="print 10 and then 5 more";
// used in the same order as described above:
str.append(str2); // "Writing "
str.append(str3,6,3); // "10 "
str.append("dots are cool",5); // "dots "
str.append("here: "); // "here: "
str.append(10u,'.'); // ".........."
str.append(str3.begin()+8,str3.end()); // " and then 5 more"
str.append<int>(5,0x2E); // "....."
std::cout << str << '\n';
return 0;
}
Writing 10 dots here: .......... and then 5 more.....